package com.dxm.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dxm.common.annotation.Log;
import com.dxm.common.base.controller.BaseController;
import com.dxm.service.OverdueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/overduelist")
@Slf4j
public class OverdueListController extends BaseController {
    @Autowired
    private OverdueService overdueService;

    /**
     * @Author zhangxingshuai
     * @Description //TODO 获取度小满逾期数据
     * @Date 16:33 2021/6/24
     * @Param [start 开始时间戳（单位：s）, end 结束时间戳, pageNum 当前页码, pageSize 分页大小]
     * @return void
     **/
    @GetMapping("/getData")
    public Result<Object> getData(Long start, Long end, Integer pageNum, Integer pageSize) {
        if (null == start || null == end) {
            return Error(HttpStatus.BAD_REQUEST,"起止时间不能为空！");
        }
        JSONObject result = overdueService.getData(start, end, pageNum, pageSize);
        String errno = result.getString("errno");
        String errmsg = result.getString("errmsg");
        JSONObject data = result.getJSONObject("data");
        if (!"0".equals(errno)) {
            return OK(errmsg);
        }
        return OK(data);
    }
}
